package edu.hcnu.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import edu.hcnu.po.User;

import java.util.LinkedList;
import java.util.List;


@RestController
@RequestMapping("/thymeleaf")
public class ThymeleafController {


    @GetMapping("/table")
    public ModelAndView getStudent(){
        List<User> users = new LinkedList<>();
        users.add(new User(1,"张三",10));
        users.add(new User(2,"李四",20));
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("users",users);
        modelAndView.setViewName("table");
        return modelAndView;
    }

    @GetMapping("/index")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        return modelAndView;
    }
}
